MIDI2LR 6.3.0.1
MIDI2LR is an application that interfaces MIDI controllers with Lightroom 6+/CC Classic. It processes MIDI input into develop parameter updates and photo actions, and sends MIDI output when parameters are changed for motorized feedback (on controllers that have motorized faders). A listing of available LightRoom commands is in the Wiki. Assistance on the code and design is welcome.
Loading...
Searching...
No Matches
TextButtonAligned Class Reference

#include <TextButtonAligned.h>

Inheritance diagram for TextButtonAligned:

Public Member Functions

 TextButtonAligned (const juce::Justification::Flags alignment)
 TextButtonAligned (const juce::String &button_name, const juce::Justification::Flags alignment)
 TextButtonAligned (const juce::String &button_name, const juce::String &tool_tip, const juce::Justification::Flags alignment)
void paintButton (juce::Graphics &, bool, bool) override

Private Member Functions

void DrawButtonText (juce::Graphics &g, TextButton &button, bool should_draw_button_as_highlighted, bool should_draw_button_as_down) const

Private Attributes

juce::Justification::Flags alignment_ {juce::Justification::centredLeft}

Constructor & Destructor Documentation

◆ TextButtonAligned() [1/3]

TextButtonAligned::TextButtonAligned ( const juce::Justification::Flags alignment)
inlineexplicit
28 : alignment_ {alignment}
29 {
30 }
juce::Justification::Flags alignment_
Definition TextButtonAligned.h:50

◆ TextButtonAligned() [2/3]

TextButtonAligned::TextButtonAligned ( const juce::String & button_name,
const juce::Justification::Flags alignment )
inline
33 : juce::TextButton(button_name), alignment_ {alignment}
34 {
35 }

References TextButtonAligned().

Referenced by TextButtonAligned().

◆ TextButtonAligned() [3/3]

TextButtonAligned::TextButtonAligned ( const juce::String & button_name,
const juce::String & tool_tip,
const juce::Justification::Flags alignment )
inline
39 : juce::TextButton(button_name, tool_tip), alignment_ {alignment}
40 {
41 }

References TextButtonAligned().

Referenced by TextButtonAligned().

Member Function Documentation

◆ DrawButtonText()

void TextButtonAligned::DrawButtonText ( juce::Graphics & g,
TextButton & button,
bool should_draw_button_as_highlighted,
bool should_draw_button_as_down ) const
private
42{
43 /* Based on drawButtonText in LookAndFeel_V2 (V3 doesn't override V2 for this call). Only change
44 * in my version is alignment on last line. */
45 const auto button_height {button.getHeight()};
46 const auto button_width {button.getWidth()};
47 const auto font {juce::Component::getLookAndFeel().getTextButtonFont(button, button_height)};
48 g.setFont(font);
49 g.setColour(button
50 .findColour(button.getToggleState() ? juce::TextButton::textColourOnId
51 : juce::TextButton::textColourOffId)
52 .withMultipliedAlpha(button.isEnabled() ? 1.0F : 0.5F));
53
54 const auto y_indent {std::min(4, button.proportionOfHeight(0.3F))}; //-V112
55 const auto min_height_width {std::min(button_height, button_width)};
56 MIDI2LR_ASSUME(min_height_width >= 0);
57 const auto corner_size {min_height_width / 2};
58 MIDI2LR_ASSUME(corner_size >= 0);
59 const auto font_height {gsl::narrow_cast<int>(font.getHeight() * 0.6F + 0.5F)};
60 const auto left_indent {
61 std::min(font_height, 2 + corner_size / (button.isConnectedOnLeft() ? 4 : 2))}; //-V112
62 const auto right_indent {
63 std::min(font_height, 2 + corner_size / (button.isConnectedOnRight() ? 4 : 2))}; //-V112
64
65 if (const auto text_width {button_width - left_indent - right_indent}; text_width > 0) {
66 g.drawFittedText(button.getButtonText(), left_indent, y_indent, text_width,
67 button_height - y_indent * 2, alignment_, 2);
68 }
69}

◆ paintButton()

void TextButtonAligned::paintButton ( juce::Graphics & g,
bool should_draw_button_as_highlighted,
bool should_draw_button_as_down )
override
27{
28 /* from TextButton.cpp: only change is second call from lf:: to TextButtonAligned:: */
29#pragma warning(suppress : 26812)
30 juce::Component::getLookAndFeel().drawButtonBackground(g, *this,
31 juce::Component::findColour(juce::Button::getToggleState()
32 ? juce::TextButton::ColourIds::buttonOnColourId
33 : juce::TextButton::ColourIds::buttonColourId),
34 should_draw_button_as_highlighted, should_draw_button_as_down);
35 /* the following normally calls lf.drawButtonText, hijacking the call for specific formatting */
36 DrawButtonText(g, *this, should_draw_button_as_highlighted, should_draw_button_as_down);
37}
void DrawButtonText(juce::Graphics &g, TextButton &button, bool should_draw_button_as_highlighted, bool should_draw_button_as_down) const
Definition TextButtonAligned.cpp:39

Member Data Documentation

◆ alignment_

juce::Justification::Flags TextButtonAligned::alignment_ {juce::Justification::centredLeft}
private
50{juce::Justification::centredLeft};

The documentation for this class was generated from the following files:
  • C:/Users/rsjaf/source/repos/MIDI2LR/src/application/TextButtonAligned.h
  • C:/Users/rsjaf/source/repos/MIDI2LR/src/application/TextButtonAligned.cpp