Merge commit '87689ccb5f' into theme
This commit is contained in:
commit
27a934ee70
27 changed files with 925 additions and 519 deletions
|
|
@ -17,6 +17,21 @@ public:
|
|||
return { r * s, g * s, b * s, a * s };
|
||||
}
|
||||
|
||||
static Colorf fromRgba(uint32_t rgba)
|
||||
{
|
||||
return fromRgba8(
|
||||
0xff & rgba>>24,
|
||||
0xff & rgba>>16,
|
||||
0xff & rgba>>8,
|
||||
0xff & rgba
|
||||
);
|
||||
}
|
||||
|
||||
static Colorf fromRgb(uint32_t rgb)
|
||||
{
|
||||
return fromRgba(rgb<<8 | 0xff);
|
||||
}
|
||||
|
||||
uint32_t toBgra8() const
|
||||
{
|
||||
uint32_t cr = (int)(std::max(std::min(r * 255.0f, 255.0f), 0.0f));
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ private:
|
|||
Colorf cursor_color;
|
||||
|
||||
std::string::size_type sel_start = 0, sel_end = 0;
|
||||
Colorf sel_foreground, sel_background = Colorf::fromRgba8(153, 201, 239);
|
||||
Colorf sel_foreground, sel_background;
|
||||
|
||||
std::string text;
|
||||
std::vector<SpanObject> objects;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,23 @@ public:
|
|||
|
||||
class WidgetTheme
|
||||
{
|
||||
struct SimpleTheme {
|
||||
const Colorf bgMain; // background
|
||||
const Colorf fgMain; //
|
||||
const Colorf bgLight; // headers / inputs
|
||||
const Colorf fgLight; //
|
||||
const Colorf bgAction; // interactive elements
|
||||
const Colorf fgAction; //
|
||||
const Colorf bgHover; // hover / highlight
|
||||
const Colorf fgHover; //
|
||||
const Colorf bgActive; // click
|
||||
const Colorf fgActive; //
|
||||
const Colorf border; // around elements
|
||||
const Colorf divider; // between elements
|
||||
};
|
||||
public:
|
||||
WidgetTheme() {}
|
||||
WidgetTheme(const struct SimpleTheme &theme);
|
||||
virtual ~WidgetTheme() = default;
|
||||
|
||||
WidgetStyle* RegisterStyle(std::unique_ptr<WidgetStyle> widgetStyle, const std::string& widgetClass);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ private:
|
|||
SpanLayout layout;
|
||||
Rect box;
|
||||
bool invalidated = true;
|
||||
|
||||
Line(const TextEdit *self)
|
||||
{
|
||||
layout.SetSelectionColors(self->selectionFG, self->selectionBG);
|
||||
}
|
||||
};
|
||||
|
||||
struct ivec2
|
||||
|
|
@ -96,9 +101,10 @@ private:
|
|||
bool operator!=(const ivec2& b) const { return x != b.x || y != b.y; }
|
||||
};
|
||||
|
||||
Colorf selectionBG, selectionFG;
|
||||
Scrollbar* vert_scrollbar;
|
||||
Timer* timer = nullptr;
|
||||
std::vector<Line> lines = { Line() };
|
||||
std::vector<Line> lines = { Line{this} };
|
||||
ivec2 cursor_pos = { 0, 0 };
|
||||
int max_length = -1;
|
||||
bool mouse_selecting = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue