nine_image_painter_factory.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_BASE_NINE_IMAGE_PAINTER_FACTORY_H_
  5. #define UI_BASE_NINE_IMAGE_PAINTER_FACTORY_H_
  6. #include <memory>
  7. #include "base/component_export.h"
  8. // A macro to define arrays of IDR constants used with CreateImageGridPainter.
  9. #define IMAGE_GRID(x) { x ## _TOP_LEFT, x ## _TOP, x ## _TOP_RIGHT, \
  10. x ## _LEFT, x ## _CENTER, x ## _RIGHT, \
  11. x ## _BOTTOM_LEFT, x ## _BOTTOM, x ## _BOTTOM_RIGHT, }
  12. // Defines an empty image for use in macros for creating an image grid for a
  13. // ring of eight images.
  14. #define EMPTY_IMAGE 0
  15. // A macro to define arrays of IDR constants used with CreateImageGridPainter
  16. // where only a ring of eight images is provided and center image is empty.
  17. #define IMAGE_GRID_NO_CENTER(x) { x ## _TOP_LEFT, x ## _TOP, x ## _TOP_RIGHT, \
  18. x ## _LEFT, EMPTY_IMAGE, x ## _RIGHT, \
  19. x ## _BOTTOM_LEFT, x ## _BOTTOM, x ## _BOTTOM_RIGHT, }
  20. // A macro to define arrays of IDR constants used with CreateImageGridPainter
  21. // where it can only be streched horizontally.
  22. #define IMAGE_GRID_HORIZONTAL(x) { x ## _LEFT, x ## _CENTER, x ## _RIGHT, \
  23. EMPTY_IMAGE, EMPTY_IMAGE, EMPTY_IMAGE, \
  24. EMPTY_IMAGE, EMPTY_IMAGE, EMPTY_IMAGE}
  25. // A macro to define arrays of IDR constants used with CreateImageGridPainter
  26. // where it can only be streched vertically.
  27. #define IMAGE_GRID_VERTICAL(x) { x ## _TOP, EMPTY_IMAGE, EMPTY_IMAGE, \
  28. x ## _CENTER, EMPTY_IMAGE, EMPTY_IMAGE, \
  29. x ## _BOTTOM, EMPTY_IMAGE, EMPTY_IMAGE}
  30. namespace gfx {
  31. class NineImagePainter;
  32. }
  33. namespace ui {
  34. // Creates a NineImagePainter from an array of image ids. It's expected the
  35. // array came from the IMAGE_GRID macro.
  36. COMPONENT_EXPORT(UI_BASE)
  37. std::unique_ptr<gfx::NineImagePainter> CreateNineImagePainter(
  38. const int image_ids[]);
  39. } // namespace ui
  40. #endif // UI_BASE_NINE_IMAGE_PAINTER_FACTORY_H_