Skip to content

Commit

Permalink
[eListbox]
Browse files Browse the repository at this point in the history
* rename setSpacerColor -> setSpacingColor

[skin]
* rename attribute spacerColor -> spacingColor
* add attribute scrollbarLength
  • Loading branch information
jbleyel committed Jun 20, 2023
1 parent f93469c commit 507d246
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
22 changes: 11 additions & 11 deletions lib/gui/elistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ int eListbox::event(int event, void *data, void *data2)
{
painter.clip(paint_region);
style->setStyle(painter, eWindowStyle::styleListboxNormal);
if (m_style.is_set.spacer_color)
painter.setBackgroundColor(m_style.m_spacer_color);
if (m_style.is_set.spacing_color)
painter.setBackgroundColor(m_style.m_spacing_color);
else
{
if (m_style.is_set.background_color)
Expand Down Expand Up @@ -548,8 +548,8 @@ int eListbox::event(int event, void *data, void *data2)
painter.clip(eRect(m_scrollbar->position(), eSize(m_scrollbar->size().width() + m_scrollbar_offset, m_scrollbar->size().height())));
}

if (m_style.is_set.spacer_color)
painter.setBackgroundColor(m_style.m_spacer_color);
if (m_style.is_set.spacing_color)
painter.setBackgroundColor(m_style.m_spacing_color);
else
{
if (m_style.is_set.background_color)
Expand All @@ -569,8 +569,8 @@ int eListbox::event(int event, void *data, void *data2)
{
painter.clip(eRect(m_scrollbar->position(), eSize(m_scrollbar->size().width(), m_scrollbar->size().height() + m_scrollbar_offset)));
}
if (m_style.is_set.spacer_color)
painter.setBackgroundColor(m_style.m_spacer_color);
if (m_style.is_set.spacing_color)
painter.setBackgroundColor(m_style.m_spacing_color);
else
{
if (m_style.is_set.background_color)
Expand All @@ -590,8 +590,8 @@ int eListbox::event(int event, void *data, void *data2)
{
painter.clip(eRect(m_scrollbar->position() - ePoint(m_scrollbar_offset, 0), eSize(m_scrollbar_offset, m_scrollbar->size().height())));
}
if (m_style.is_set.spacer_color)
painter.setBackgroundColor(m_style.m_spacer_color);
if (m_style.is_set.spacing_color)
painter.setBackgroundColor(m_style.m_spacing_color);
else
{
if (m_style.is_set.background_color)
Expand Down Expand Up @@ -925,10 +925,10 @@ void eListbox::entryReset(bool selectionHome)
invalidate();
}

void eListbox::setSpacerColor(gRGB &col)
void eListbox::setSpacingColor(gRGB &col)
{
m_style.m_spacer_color = col;
m_style.is_set.spacer_color = 1;
m_style.m_spacing_color = col;
m_style.is_set.spacing_color = 1;
}

void eListbox::setBackgroundColor(gRGB &col)
Expand Down
8 changes: 4 additions & 4 deletions lib/gui/elistbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct eListboxStyleSetted
bool scrollbarbackground_color : 1;
bool scollbarborder_color : 1;
bool scrollbarborder_width : 1;
bool spacer_color : 1;
bool spacing_color : 1;
bool overlay : 1;
bool max_rows : 1;
bool max_columns : 1;
Expand All @@ -83,7 +83,7 @@ struct eListboxStyleSetted
struct eListboxStyle
{
ePtr<gPixmap> m_background, m_selection, m_overlay;
gRGB m_background_color, m_background_color_selected, m_foreground_color, m_foreground_color_selected, m_border_color, m_scollbarborder_color, m_scrollbarforeground_color, m_scrollbarbackground_color, m_spacer_color;
gRGB m_background_color, m_background_color_selected, m_foreground_color, m_foreground_color_selected, m_border_color, m_scollbarborder_color, m_scrollbarforeground_color, m_scrollbarbackground_color, m_spacing_color;
int m_max_columns;
int m_max_rows;
float m_selection_zoom;
Expand Down Expand Up @@ -256,8 +256,8 @@ class eListbox : public eWidget
void setForegroundColor(gRGB &col);
void setForegroundColorSelected(gRGB &col);

void setSpacerColor(gRGB &col);
void clearSpacerColor() { m_style.is_set.spacer_color = 0; }
void setSpacingColor(gRGB &col);
void clearSpacingColor() { m_style.is_set.spacing_color = 0; }

void clearBackgroundColor() { m_style.is_set.background_color = 0; }
void clearBackgroundColorSelected() { m_style.is_set.background_color_selected = 0; }
Expand Down
17 changes: 15 additions & 2 deletions lib/python/skin.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,16 @@ def parseItemAlignment(value):
return parseOptions(options, "itemAlignment", value, eListbox.itemAlignDefault)


def parseScrollbarLength(value, default):
if value and value.isdigit():
return int(value)
options = {
"full": 0,
"auto": -1
}
return options.get(value, default)


def parseListOrientation(value):
options = {
"vertical": 0b01,
Expand Down Expand Up @@ -923,6 +933,9 @@ def scrollbarBackgroundColor(self, value):
def scrollbarBorderColor(self, value):
self.guiObject.setScrollbarBorderColor(parseColor(value, 0x00FFFFFF))

def scrollbarLength(self, value):
self.guiObject.setScrollbarLength(parseScrollbarLength(value, 0))

def scrollbarSliderBorderColor(self, value): # This legacy definition uses an inconsistent name, use'scrollbarBorderColor' instead!
self.scrollbarBorderColor(value)
attribDeprecationWarning("scrollbarSliderBorderColor", "scrollbarBorderColor")
Expand Down Expand Up @@ -1003,8 +1016,8 @@ def sliderPixmap(self, value): # For compatibility same as 'scrollbarSliderPixm
self.scrollbarForegroundPixmap(value)
attribDeprecationWarning("sliderPixmap", "scrollbarForegroundPixmap")

def spacerColor(self, value):
self.guiObject.setSpacerColor(parseColor(value, 0x00000000))
def spacingColor(self, value):
self.guiObject.setSpacingColor(parseColor(value, 0x00000000))

def text(self, value):
if value:
Expand Down

0 comments on commit 507d246

Please sign in to comment.